package com.processmining.filter.handler;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.processmining.util.exception.FileSizeException;
import com.processmining.util.exception.NoAuthorityException;
import com.processmining.util.response.Code;
import com.processmining.util.response.ResponseData;

@ControllerAdvice
public class CustomExceptionHandler {
      @ResponseBody
      @ExceptionHandler(NoAuthorityException.class)
      public ResponseData handleNoAuthorityException(){
    	  ResponseData respData = new ResponseData(Code.NOT_LOGGED);
    	  return respData;
      }
      
      
      @ResponseBody
      @ExceptionHandler(FileSizeException.class)
      public ResponseData handleFileSizeException(){
    	  ResponseData respData = new ResponseData(Code.ZERO_FILE_SIZE);
    	  return respData;
      }
      
      
      @ResponseBody
      @ExceptionHandler(FileNotFoundException.class)
      public ResponseData handleFileNotFoundException(FileNotFoundException e){
    	  e.printStackTrace();
    	  ResponseData respData = new ResponseData(Code.FILE_NOT_FOUND);
    	  return respData;
      }
      
      @ResponseBody
      //@ExceptionHandler(Exception.class)
      public ResponseData handleException(Exception e){
    	  e.printStackTrace();
    	  ResponseData respData = new ResponseData(Code.UNKNOWN_FAULT);
    	  return respData;
      }
      


      
}
